<?php

namespace app\controller\admin;

use app\BaseController;
use think\response\Json;

class Supplier extends BaseController
{
    public function lst(): Json
    {
        return $this->success($this->app->make(\app\model\Supplier::class)->getPage());
    }

    public function detail(): Json
    {
        return $this->success($this->app->make(\app\model\Supplier::class)->detail());
    }

    public function save(): Json
    {
        if(!$this->request->isPost()) throw new \Exception("请求方式错误", 7001);
        return $this->success($this->app->make(\app\model\Supplier::class)->updateOrAdd());
    }

    public function delete(): Json
    {
        if(!$this->request->isDelete()) throw new \Exception("请求方式错误", 7001);
        return $this->success($this->app->make(\app\model\Supplier::class)->del());
    }

    public function supplierSearch(): Json
    {
        return $this->success($this->app->make(\app\model\Supplier::class)->supplierSearch());
    }
}
